package edu.csusm.spotrobot;

import com.sun.spot.sensorboard.EDemoBoard;
import com.sun.spot.sensorboard.io.IIOPin;

/**
 *
 * Simply checks to see if the pin that the beacon sensor was defined to be on
 * during construction is high.
 *
 * @author Zebulon Evans
 */
public class BeaconSensor {
    EDemoBoard demo = EDemoBoard.getInstance();
    /** 
     * The IO pin that the beacon sensor is hooked up to.  Will go high if the
     * 38kHz signal that the iRobot Roomba bases station is detected.
     */
    IIOPin beaconPin;
    
    /**
     * Create a new BeaconSensor.
     * @param int pin on the SunSPOT that the beacon sensor is connected to
     */
    public BeaconSensor( int beaconPinIn ){
       beaconPin = demo.getIOPins()[beaconPinIn];
    }
    
    /**
     * Detect if the beacon is high or low.
     *
     * @return boolean true if the beacon is detecting a 38kHz modulated signal
     */
    public boolean detect(){
        return beaconPin.isHigh();
    }
}
